//
//  QLPlayerManager.m
//  WeiMiLan
//
//  Created by anan on 14/11/8.
//  Copyright (c) 2014年 Mac. All rights reserved.
//

#import "QLPlayerManager.h"

@implementation QLPlayerManager

+ (void)openBrowserWithUrl:(NSString *)url title:(NSString*)title userId:(NSString*)userId viewController:(UIViewController*)viewController;
{
    TRSendWebViewController * vc = [[self getStoryboard] instantiateViewControllerWithIdentifier:@"TRSendWebViewController"];
    
    vc.pushUrl = [NSURL URLWithString:[url stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
    vc.title = title;
    vc.userId = userId;
    [viewController presentViewController:vc animated:YES completion:^{
        
    }];
}

+ (void)openProductDetailWithId:(NSString*)keyId viewController:(UIViewController*)viewController
{
    
    TRProductDetailViewController *vc = [[TRProductDetailViewController alloc] init];
    vc.productTypeId = keyId;
    [viewController presentViewController:vc animated:YES completion:^{
        
    }];
}

+ (void)openUserHomeWithId:(int)userId viewController:(UIViewController*)viewController
{
    TRUserhomeViewController *vc = [[TRUserhomeViewController alloc] init];
    vc.userId = userId;
  //  UINavigationController *nav = [[UINavigationController alloc]initWithRootViewController:vc];
    [viewController presentViewController:vc animated:YES completion:^{
        
    }];
   // [viewController.navigationController pushViewController:vc animated:YES];
}

+ (UIStoryboard*)getStoryboard
{
    TRAppDelegate *app = (TRAppDelegate*)([UIApplication sharedApplication].delegate);
    DDMenuController * ddmenu = (DDMenuController *)app.window.rootViewController;
    TRTabBarViewController * tabvc= (TRTabBarViewController *)ddmenu.rootViewController;
    UIStoryboard *storyboard = tabvc.storyboard;
    return storyboard;
}

+ (void)openQQWithviewController:(UIViewController*)viewController account:(NSString*)account
{
    //    NSString *url = [NSString stringWithFormat:@"http://wpa.qq.com/msgrd?v=3&uin=%@&site=qq&menu=yes",account];
    //    //[self openBrowserWithUrl:url title:@"qq" userId:nil viewController:viewController];
    //    [[UIApplication sharedApplication] openURL:[NSURL URLWithString:url]];
    
    QQApiWPAObject *wpaObj = [QQApiWPAObject objectWithUin:account];
    SendMessageToQQReq *req = [SendMessageToQQReq reqWithContent:wpaObj];
    [QQApiInterface sendReq:req];
}

@end
